package com.usian.admin.listener;

import com.usian.admin.service.NewsAutoScanService;
import com.usian.common.constants.NewsConstant;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class KafkaReceiveMessage {
    @Autowired
    private NewsAutoScanService service;
    @KafkaListener(topics = {NewsConstant.WM_NEWS_AUTO_SCAN_TOPIC})
    public void receiveMessage(ConsumerRecord record){
        Object value = record.value();
        Long newsId = Long.valueOf(value.toString());
        service.autoScan(newsId);
    }
}
